10 ' mandelx1.bas - FreeWare 2005
20 GOTO 60 ' begin
30 SAVE "mandelx1.bas",A:LIST-40
40 GOTO 420 ' wait for key
50 GOTO 450 ' centered text
60 DEFSTR M,Q:Q=MKI$(0):SCREEN 9
70 CLS:WINDOW (-320,-240)-(319,239)
80 DELH=1.6:DELV=1.34:AC=-.65
90 N1=260:N2=INT(N1*DELV/DELH)
100 DIM COL(8):DATA 0,1,9,2,10,4,12,6,14
110 FOR I=0 TO 8:READ COL(I):NEXT
120 M(1)="MANDELBROT idea from Hans Lauwerier"
130 M(2)="GWBASIC by Eric Tchong"
140 M(3)="Press any key to generate fractal"
150 FOR I=1 TO 3
160  GOSUB 50
170  IF I=2 THEN PRINT
180 NEXT:GOSUB 40:CLS
190 ' main
200 LINE (N1+1,N2+1)-(-N1-1,-N2-1),4,B
210 FOR I=-N1 TO N1:A=AC+I*DELH/N1
220  FOR J=0 TO N2:B=J*DELV/N2
230   U=4*(A*A+B*B):V=U-2*A+1/4
240   IF U+8*A+15/4<0 THEN L=0:GOTO 360
250   IF V-SQR(V)+2*A-1/2<0 THEN L=0:GOTO 360
260   X=A:Y=B:K=0
270   LSET Q=MKI$(0)
280    WHILE CVI(Q)=0
290     Z=X:X=X*X-Y*Y+A:Y=2*Z*Y+B
300     S=X*X+Y*Y:K=K+1
310     IF S>100 OR K=50 THEN 340
320    WEND
330   GOTO 270
340   IF K<40 THEN L=1+K MOD 8 ELSE L=0
350   IF K>3 THEN PSET (I,J),COL(L):PSET (I,-J),COL(L)
360   IF INKEY$<>"" THEN 390
370  NEXT
380 NEXT
390 GOSUB 40
400 SCREEN 0,0,0:CLS:END
410 ' wait for key
420 LSET Q=MKI$(0)
430 WHILE CVI(Q)=0:MID$(Q,1)=INKEY$:WEND:RETURN
440 ' centered text
450 X=(80-LEN(M(I)))/2
460 PRINT TAB(X) M(I):RETURN
